<extend name="./Application/Admin/View/Layout/application.html"/>
<block name="content">
    <div class="row">
        <div class="col-md-9">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">栏目管理</h3>
                </div>
                <div class="panel-body">
                    <form action="" method="post" id="form">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>是否显示</th>
                                <th>排序</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <volist name="categories" id="category">
                                <tr data-id="{{$category.id}}">
                                    <th scope="row">{{$category.id}}</th>
                                    <td class="name">{{$category.name}}</td>
                                    <td>
                                        <eq name="category.is_show" value="1">
                                            <span class="glyphicon glyphicon-ok"></span>
                                            <else/>
                                            <span class="glyphicon glyphicon-remove"></span>
                                        </eq>
                                    </td>
                                    <td>
                                        <input type="text" name="sort_order[]" value="{{$category.sort_order}}">
                                    </td>
                                    <td>
                                        <a href="{{:U('edit',array('id'=>$category['id']))}}" class="edit">
                                            <span class="glyphicon glyphicon-pencil"></span>
                                        </a>
                                        <a href="javascript: void 0;" class="delete" data-toggle="modal"
                                           data-target="#deleteCategory">
                                            <span class="glyphicon glyphicon-trash"></span>
                                        </a>
                                    </td>
                                </tr>
                                <volist name="category.children" id="child">
                                    <tr data-id="{{$child.id}}">
                                        <th scope="row">{{$child.id}}</th>
                                        <td class="name">
                                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--{{$child.name}}
                                        </td>
                                        <td>
                                            <eq name="child.is_show" value="1">
                                                <span class="glyphicon glyphicon-ok"></span>
                                                <else/>
                                                <span class="glyphicon glyphicon-remove"></span>
                                            </eq>
                                        </td>
                                        <td>
                                            <input type="text" name="sort_order[]" value="99">
                                        </td>
                                        <td>
                                            <a href="{{:U('edit',array('id'=>$child['id']))}}" class="edit">
                                                <span class="glyphicon glyphicon-pencil"></span>
                                            </a>
                                            <a href="javascript: void 0;" class="delete" data-toggle="modal"
                                               data-target="#deleteCategory">
                                                <span class="glyphicon glyphicon-trash"></span>
                                            </a>
                                        </td>
                                    </tr>
                                </volist>
                            </volist>
                        </table>
                    </form>
                </div>
            </div>
        </div>

        <div class="col-md-3">
            <div class="list-group">
                <a href="{{:U('add')}}" class="list-group-item list-group-item-info">
                    新增
                </a>
                <a href="javascript: void 0;" class="list-group-item list-group-item-success">排序</a>
            </div>
        </div>
    </div>

    <!--删除-->
    <div class="modal fade" id="deleteCategory" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">

            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="ModalLabel">删除友情链接</h4>
                </div>

                <div class="modal-body">
                    <p>确认要删除当前友情链接吗？</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
                    <a type="submit" class="btn btn-danger delete_confirm">确 认</a>
                </div>
            </div>
        </div>
    </div>
</block>

<block name="js">
    <script>
        $(function () {
            $('.delete').click(function () {
                var id = $(this).parents('tr').attr('data-id');
                var href = "/Admin/Category/delete/id/" + id;
                $('.delete_confirm').attr('href', href);
            })
        })
    </script>
</block>